package com.esri.core.internal.catalog;

import androidx.core.app.NotificationCompat;
import com.esri.core.internal.io.handler.a;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class User implements PageableResultType {
    private String a;
    private String b;
    private String c;
    private List<String> d;
    private Group e;
    private String f;
    private String g;
    private String h;
    private String i;
    private Date j;
    private List<Group> k;
    private Catalog l;
    private String m;
    private long n;
    private long o;
    private String p;
    private byte[] q;
    private Date r;
    private List<String> s;

    /* loaded from: classes.dex */
    public enum SortField {
        USER_NAME { // from class: com.esri.core.internal.catalog.User.SortField.1
            @Override // java.lang.Enum
            public String toString() {
                return "username";
            }
        },
        CREATED { // from class: com.esri.core.internal.catalog.User.SortField.2
            @Override // java.lang.Enum
            public String toString() {
                return "created";
            }
        }
    }

    public String getUserName() {
        return this.a;
    }

    public String getFullName() {
        return this.b;
    }

    public String getPreferredView() {
        return this.c;
    }

    public List<String> getClientApps() {
        return this.d;
    }

    public Group getDefaultGroup() {
        List<Group> list;
        if (this.e == null && (list = this.k) != null && list.size() > 0) {
            for (Group group : this.k) {
                if (group.getId().equals(this.m)) {
                    this.e = group;
                }
            }
        }
        return this.e;
    }

    public String getDescription() {
        return this.f;
    }

    public String getEmail() {
        return this.g;
    }

    public String getPrivacy() {
        return this.h;
    }

    public String getOrganization() {
        return this.i;
    }

    public Date getCreated() {
        return this.j;
    }

    public List<Group> getGroups() {
        return this.k;
    }

    public List<String> getTags() {
        return this.s;
    }

    public long getStorageUsage() {
        return this.n;
    }

    public long getStorageQuota() {
        return this.o;
    }

    public byte[] getThumbnail() {
        try {
            if (this.q == null) {
                String str = this.l.getUrl() + "/sharing/community/users/" + this.a + "/info/" + this.p;
                HashMap hashMap = new HashMap();
                if (this.l.getUserToken() != null) {
                    hashMap = new HashMap();
                    hashMap.put("token", this.l.getUserToken());
                }
                this.q = a.a(str, hashMap);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return this.q;
    }

    public Date getModifiedDate() {
        return this.r;
    }

    @Override // com.esri.core.internal.catalog.PageableResultType
    public boolean fromJson(JsonParser jsonParser, Filter filter, Catalog catalog) {
        this.l = catalog;
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            try {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if (currentName.equals("username")) {
                    this.a = jsonParser.getText();
                } else if (currentName.equals("fullName")) {
                    this.b = jsonParser.getText();
                } else if (currentName.equals("preferredView")) {
                    this.c = jsonParser.getText();
                } else if (currentName.equals("clientApps")) {
                    String text = jsonParser.getText();
                    this.d = new ArrayList();
                    StringTokenizer stringTokenizer = new StringTokenizer(text, ",");
                    while (stringTokenizer.hasMoreTokens()) {
                        this.d.add(stringTokenizer.nextToken());
                    }
                } else if (currentName.equals("defaultGroupId")) {
                    this.m = jsonParser.getText();
                } else if (currentName.equals("description")) {
                    this.f = jsonParser.getText();
                } else if (currentName.equals(NotificationCompat.CATEGORY_EMAIL)) {
                    this.g = jsonParser.getText();
                } else if (currentName.equals("privacy")) {
                    this.h = jsonParser.getText();
                } else if (currentName.equals("storageUsage")) {
                    this.n = jsonParser.getLongValue();
                } else if (currentName.equals("storageQuota")) {
                    this.o = jsonParser.getLongValue();
                } else if (currentName.equals("organization")) {
                    this.i = jsonParser.getText();
                } else if (currentName.equals("tags")) {
                    this.s = new ArrayList();
                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                        this.s.add(jsonParser.getText());
                    }
                } else if (currentName.equals("thumbnail")) {
                    this.p = jsonParser.getText();
                } else if (currentName.equals("created")) {
                    this.j = new Date(jsonParser.getLongValue());
                } else if (currentName.equals("modified")) {
                    this.r = new Date(jsonParser.getLongValue());
                } else if (currentName.equals("groups")) {
                    if (this.k == null) {
                        this.k = new ArrayList();
                    }
                    while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                        Group group = new Group();
                        group.fromJson(jsonParser, null, this.l);
                        group.testAndSetOwner(this);
                        this.k.add(group);
                    }
                } else {
                    PrintStream printStream = System.err;
                    printStream.println("Skipping " + currentName);
                    jsonParser.skipChildren();
                }
            } catch (Exception e) {
                e.printStackTrace();
                return true;
            }
        }
        return true;
    }

    @Override // com.esri.core.internal.catalog.PageableResultType
    public <T extends PageableResultType> int compare(T t) {
        User user = (User) t;
        if (this.j.before(user.j)) {
            return -1;
        }
        return this.j.after(user.j) ? 1 : 0;
    }
}
